package com.tanhua.manage.job;

import com.tanhua.dubbo.api.VoiceApi;
import com.tanhua.manage.service.AnalysisByDayService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务类
 */
@Component
@Slf4j
public class AnalysisJob {

    @Autowired
    private AnalysisByDayService analysisByDayService;

    // 每隔5s执行一次
    @Scheduled(cron = "0 0/5 * * * ?") // 指定执行时机间隔
    public void analysis(){
        // 查询log表里，登录数、新增用户数、活跃用户数、次日留存数
        log.info("统计开始执行");
        analysisByDayService.analysis();
        log.info("统计结束执行");
    }


    @Reference
    private VoiceApi voiceApi;
    // 每隔1天执行一次
    @Scheduled(cron = "0 0 0 1 * ?") // 指定执行时机间隔
//    @Scheduled(cron = "0 0/1 * * * ?") // 指定执行时机间隔
    public void resetRecieveVoice(){
        //刷新桃花传音使用次数
        log.info("统计开始执行重置10次接收语音");
        voiceApi.setVoice();
        log.info("统计结束执行重置10次接收语音");
    }
}
